package com.awesome.spring.es.entity;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;
import java.util.Date;

/**
 * @program: awesome-spring
 * @description: 内容索引
 * @author: Alex Wu
 * @createDate: 2025-03-03 15:54
 **/

@Data
@Document(indexName = "contents_index", createIndex = false)
public class ContentsIndex implements Serializable {

    private static final long serialVersionUID=1L;

    @Field(type= FieldType.Integer)
    private Integer id;

    @Field(type= FieldType.Keyword)
    private String title;

    @Field(type= FieldType.Keyword) // 不分词，只能完全匹配，不支持模糊搜索，适用精确匹配
    private String intro;

    @Field(type= FieldType.Text)  // Text类型支持分词, 不适用精确匹配、排序、聚合（统计）
    private String content;

    @Field(type= FieldType.Integer)
    private Integer createId;

    @Field(type= FieldType.Keyword)
    private String createName;

    @Field(type= FieldType.Date,format = DateFormat.date_hour_minute_second)
    private Date createTime;
}
